package edu.hm.swe2.shareit.domain;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.DiscriminatorColumn;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.OneToMany;

@Entity
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="RESOURCEN_TYP")
public abstract class Resource {
	
	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE)
	protected int id;
	protected String titel;
	
	@OneToMany(mappedBy="resource")
	protected List<Exemplar> exemplare = new ArrayList<Exemplar>();

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getTitel() {
		return titel;
	}

	public void setTitel(String titel) {
		this.titel = titel;
	}

	public List<Exemplar> getExemplare() {
		return exemplare;
	}

	public void setExemplar(List<Exemplar> exemplare) {
		this.exemplare = new ArrayList<Exemplar>(exemplare);
	}

}
